let ajax = {
    get: function({
        url,
        data = {}
    }) {
        return new Promise((res, rej) => {
            let x = new XMLHttpRequest();
            // {c:'i'} => c=i
            console.log(data);
            let str = Object.keys(data).map(item => `${item}=${data[item]}`).join('&');
            x.open('get', url + '?' + str);
            x.send();
            x.onreadystatechange = function() {
                if (x.readyState === 4) {
                    if (x.status >= 200 && x.status < 300) {
                        res({
                            code: 200,
                            msg: "获取成功",
                            data: JSON.parse(x.response)
                        })
                    } else {
                        rej(x.status)
                    }
                }
            }
        })
    },
    post: function() {

    }
}